//
//  BrowseCollectionView.m
//  bh
//
//  Created by lanou on 15/12/21.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "BrowseCollectionView.h"
#import "BrowsePhotosTableViewCell.h"
#import "BrowseDetailModel.h"
@implementation BrowseCollectionView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
      
        //创建一个布局对象
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
        //列距
        flowLayout.minimumInteritemSpacing = 10;
        //行距
        flowLayout.minimumLineSpacing = 10;
        //分区内边距
        flowLayout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
        //itemSize 设置为一行两列
        CGFloat itemWidth = (kWidth - 10 - 10) / 6;
        flowLayout.itemSize = CGSizeMake(itemWidth, itemWidth);
        flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
        _personalPictureView = [[UIImageView alloc]initWithFrame:(CGRectMake(5, kHeight / 8 + 10, 20, 20))];
        _personalPictureView.layer.masksToBounds = YES;
        _personalPictureView.layer.borderWidth = 2;
        _personalPictureView.layer.cornerRadius = _personalPictureView.bounds.size.height / 2;
        _personalPictureView.layer.borderColor = [[UIColor whiteColor]CGColor];
        [self addSubview:_personalPictureView];
        
    }
    return self;
}

- (void)setModel:(BrowseDetailModel *)model {
    [_personalPictureView setImageWithURL:[NSURL URLWithString:model.author_face]];
}





/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
